package cn.wanho.controller;

import cn.wanho.rvo.ResultVO;
import cn.wanho.service.user.ClassService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.xml.crypto.Data;
import java.util.Date;

/**
 * @Author Zxy
 * @Date 2022/8/5 16:31
 * @Version 1.0
 */

@RestController
@RequestMapping("/class")
public class ClassController {
    @Resource
    private ClassService classService;

    /**
     * @author zxy
     * @date 2022/8/5
     * 将老师阶段试卷绑定 到班级
     * 班级 阶段 老师 开始 结束
     */
    @PostMapping("/createClassStage")
    public ResultVO createClassStage(Integer classId, Integer stageId, Integer teacherId, Date startTime, Date endTime,Integer paperId, HttpServletRequest request) {
        return classService.createClassStage(classId,stageId,teacherId,startTime,endTime,paperId,request);
    }
    /**
     * @author zxy
     * @date 2022/8/6
     * createClassStudent绑定学生到班级
     */
    @PostMapping("/createClassStudent")
    public ResultVO createClassStudent(Integer classId,Integer studentId,HttpServletRequest request){
        return classService.createClassStudent(classId,studentId,request);
    }

    /**
     * 创建班级
     * @param className
     * @param request
     * @return
     */
    @PostMapping("/createclass")
    public ResultVO createClass(String className, HttpServletRequest request){
        Integer id = (Integer) request.getAttribute("userId");
        return classService.createClass(className,id);
    }

    /**
     * 创建阶段
     * @param stageName
     * @param request
     * @return
     */
    @PostMapping("/createstage")
    public ResultVO createStage(String stageName, HttpServletRequest request){
        Integer id = (Integer) request.getAttribute("userId");
        return classService.createStage(stageName,id);
    }

    /**
     * 查询所有学生的考试情况
     */
    @GetMapping("/queryAllStudentScore")
    public ResultVO queryAllStudentScore(String className,
                                         String teacherName,
                                         String studentName,
                                         String stageName,HttpServletRequest request){
        return classService.queryAllStudentScore(className,teacherName,studentName,stageName);
    }

}
